class GzipFilter
  # Do output compression if the client supports it
  def self.filter(controller)
    if controller.request.env['HTTP_ACCEPT_ENCODING'].match(/gzip/)
      if controller.response.headers["Content-Transfer-Encoding"] != 'binary'
        controller.response.body = ActiveSupport::Gzip.compress(controller.response.body)
        controller.response.headers['Content-Encoding'] = 'gzip'
      end
    end
  end
end
class ApplicationController < ActionController::Base
  after_filter GzipFilter
  protect_from_forgery
end

